<?php

namespace App\Http\Controllers\Front;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Session,Auth;
use App\Models\User;
use App\Interfaces\UserCollectionService;

class MyHomeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request,UserCollectionService $userCollectionService)
    {
        $user = Auth::user();
        $page =$request->get('page');
        $type = $request->get('type');

        $goodsCollection = $userCollectionService->lists(Auth::user()->id,'goods',$page);

        $shopCollection = $userCollectionService->lists(Auth::user()->id,'SHOP',$page);

        if ($type=='GOODS'||$type==''){
            $userCollection = $goodsCollection;
        }else{
            $userCollection = $shopCollection;
        }
        $filter = ['type'=>$type];
        return view('front.my.home',compact('user','userCollection','request'));
    }

    public function getUserInfo()
    {
        //$user = Auth::user();
        //dd($user);
        //$user = User::where('user_name',Session::get('user_name'))->get();

        return view('front.my.user_info',compact('user'));

    }

    public function getAddress()
    {
        return view('front.my.address');
    }

    public function getSafe()
    {
        return view('front.my.safe');
    }

}
